package service;

import dao.*;
import java.util.*;

public class GoodsManager {
	private GoodsDetailDAO goodsDetaildao;
	private GoodsTypeDAO goodsTypedao;

	public GoodsTypeDAO getGoodsTypedao() {
		return goodsTypedao;
	}

	public void setGoodsTypedao(GoodsTypeDAO goodsTypedao) {
		this.goodsTypedao = goodsTypedao;
	}
	
	public GoodsDetailDAO getGoodsDetaildao() {
		return goodsDetaildao;
	}

	public void setGoodsDetaildao(GoodsDetailDAO goodsDetaildao) {
		this.goodsDetaildao = goodsDetaildao;
	}

	public List findtype(){
		return getGoodsTypedao().findAll();
	}
	
	public List classify(int goodsTypeId){
		List all = getGoodsDetaildao().findAll();
		List list = new ArrayList();
		GoodsDetail goodsDetail;
		
		for(int i = 0 ; i < all.size() ; i++){
			goodsDetail = (GoodsDetail)all.get(i);
			if(goodsDetail.getGoodsType().getTypeId() == goodsTypeId){
				list.add(goodsDetail);
			}
		}
		return list;
	}

}
